package com.example.zoom001;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

import com.example.zoom001.util.Displayutil;
import com.example.zoom001.util.Utils;

public class MainActivity extends AppCompatActivity {

    private TextView text_screen;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        text_screen = findViewById(R.id.text_screen);

        int dip_10 = Utils.dip2px(this,10L);

        text_screen.setPadding(dip_10, dip_10, dip_10, dip_10);
        text_screen.setBackgroundColor(0xff00ffff);
        text_screen.setTextColor(0xf333333);

        showScreenInfo();
    }

    private void showScreenInfo(){
        int width= Displayutil.DisplayUtil.getScreenWidth(this);
        int height=Displayutil.DisplayUtil.getScreenHeigth(this);
        float sensity=Displayutil.DisplayUtil.getScreenDensity(this);
        String info=String.format("当前屏幕宽度%dpx,高度%dpx,像素密度%f",width,height,sensity);
        text_screen.setText(info);
    }
}